<?PHP
// vim: set expandtab tabstop=4 shiftwidth=4:
// +----------------------------------------------------------------------+
// | Communicator for the SAPID CMS                               		  |
// +----------------------------------------------------------------------+
// | Author:  Dmitry Sheiko (www.cmsdevelopment.com)	                  |
// | Copyright (c) 2004 Dmitry Sheiko	                                  |
// | http://sapid.sourceforge.net	                                      |
// +----------------------------------------------------------------------+
// | This source file is free software; you can redistribute it and/or    |
// | modify it under the terms of the GNU Lesser General Public           |
// | License as published by the Free Software Foundation; either         |
// | version 2.1 of the License, or (at your option) any later version.   |
// |                                                                      |
// | This source file is distributed in the hope that it will be useful,  |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    |
// | Lesser General Public License for more details.                      |
// +----------------------------------------------------------------------+
// Release: 18.11.04 (dd/mm/yy)
// $Id: chat_form.inc.php,v 1.1.1.1 2005/06/13 07:20:26 mephius Exp $

	$data=@file($server_path."getuserinfo.php?id_of_user=".$common["ID_OF_USER"]);
	if($common["ID_OF_USER"] and is_array($data)) {
		$info = join("", $data);
		$common["NAME_OF_USER"] = preg_replace("/^.*?<name_of_user>(.*?)<\/name_of_user>.*?$/is", "\\1", $info);
		$common["DESCRIPTION_OF_USER"] = preg_replace("/^.*?<description_of_user>(.*?)<\/description_of_user>.*?$/is", "\\1", $info);
		$common["ICON_OF_USER"] = preg_replace("/^.*?<icon_of_user>(.*?)<\/icon_of_user>.*?$/is", "\\1", $info);
		$common["ICON_OF_USER"] = trim($common["ICON_OF_USER"]);
	}


if($_GET["language"]) $language = $_GET["language"];
else $language = $default_language;

	$limit = 10;
	$offset = 0;

	$data=@file($server_path.'address.php');
	if(is_array($data))
	$addreslist = join("", $data);
	$serverrequest = $server_path.'chat.php?id_of_user='.$common["ID_OF_USER"].'&language='.$language;
	
	// Navigation
	$_begin = '<a target="chat" href="'.$serverrequest.'&navigation=tobegin"><img src="'.$http_path.'usr/system/images/_begin.gif"  width="12" height="14" style="margin-right: 5px" alt="To begin" border="0" /></a>';
	$_prev = '<a target="chat" href="'.$serverrequest.'&offset='.($offset+=$limit).'"><img src="'.$http_path.'usr/system/images/_prev.gif"  width="12" height="14" style="margin-right: 5px" alt="Prev 10" border="0" /></a>'; 
	$_next = '<a target="chat"  href="'.$serverrequest.'&offset='.($offset-=$limit).'"><img src="'.$http_path.'usr/system/images/_next.gif"  width="12" height="14" style="margin-right: 5px" alt="Next 10" border="0" /></a>';
	$_end = '<a target="chat"  href="'.$serverrequest.'&navigation=toend"><img src="'.$http_path.'usr/system/images/_end.gif"  width="12" height="14" style="margin-right: 5px" alt="To end" border="0" /></a>';

	echo('
		<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
		
		<html>
		<head>
			<title>'.$lang["ChatOfCommunicator"].'</title>
		<link rel="stylesheet" type="text/css" href="'.$http_path.'usr/system/default.css" />

		<script language="jscript">
		function empty_checkboxs(obj) {
			for(i=0;i<obj.length;i++) {
				if(chat_form[i].type=="checkbox") chat_form[i].checked=\'\';
			}
		} 
	
		function empty_radio(obj) {
			for(i=0;i<obj.length;i++) {
				if(chat_form[i].type=="radio") chat_form[i].checked=\'\';
			}
		} 
		</script>
		</head>
		
	<body marginwidth="0" marginheight="0" style="margin:0px">		
	
	<form target="chat" name="chat_form" action="'.$server_path.'chat.php" method="post" enctype="multipart/form-data" style="padding: 0px 0px 0px 0px">
	<input type="HIDDEN" name="id_of_user" value="'.$common["ID_OF_USER"].'" />
	<input type="HIDDEN" name="language" value="'.$language.'" />
	<input type="HIDDEN" name="redirect" value="'.$http_path.'usr/system/communicator/index.php" />
	
	<table class="tpanel" height="100%" style="width: 100%;" cellspacing="0" cellpadding="0" border="0">
		<tr>
			<td colspan="2" class="header" style="text-align: center;">
				<b>'.$lang["ChatOfCommunicator"].'</b>
			</td>
		</tr>
		<tr>
			<td width="400" height="100%" valign="top" style="vertical-align: top; padding: 7px 5px 5px 5px; font-family: Tahoma, Arial; font-size: 11px; text-align: center">

				'.$lang["Channels"].': '.($language=="ru"?
				'<a href="?language=en">English</a> <b>[ Russian ]</b> ':
				'<b>[ English ]</b> <a href="?language=ru">Russian</a>'	).'
				
				
				
			<table width="400" cellpadding="0" cellspacing="0" border="0" style="padding:5px 0px 5px 0px; font-family: Tahoma, Arial; font-size: 11px;"> 
				<tr>
				<td valign="top" colspan="2">
				<iframe SRC="'.$serverrequest.'" width="100%" onLoad="chat_form.message.value=\'\'; chat_form.attach.value=\'\';" frameborder="text/html" style="background-color: #CEE4F2; border: 1px solid white; margin: 5px 0px 5px 0px" height="200" id="chat" name="chat"></iframe>
				
				<div align="center">'.$_begin.''.$_prev.''.$_next.''.$_end.'</div>
				
				</td>
				<tr>
					<td valign="top" nowrap="nowrap" align="center" style="border-bottom: solid 1px #B5D1E4">
					'.($common["ICON_OF_USER"] ? '<img src="'.$server_path.'images/'.$common["ICON_OF_USER"].'" width="62" height="62" alt="" style="border: solid 2px white; margin: 5px 5px 5px 5px" border="0" /><br />':'').'	
					<b>'.substr($common["NAME_OF_USER"],0,15).'</b><br />
					<a href="index.php?action=register">'.$lang["Edit"].'</a>
				
						
					</td>
					<td width="300" style="border-bottom: solid 1px #B5D1E4">
						'.$lang["YourMessage"].': <br />
						<textarea style="width: 100%;  background-color: #CEE4F2; font-family: Tahoma, Arial; font-size: 11px;" rows="5" name="message"></textarea>
						'.$lang["Attach"].': <input type="file" style="width: 200;  background-color: #CEE4F2; font-family: Tahoma, Arial; font-size: 11px;" name="attach" />
				
				<div align="center" style="padding: 5px 5px 5px 5px">
					<input type="button" onclick="chat.location.href=\''.$server_path.'chat.php?id_of_user='.$common["ID_OF_USER"].'&language='.$language.'\';" name="ref" value="'.$lang["Refresh"].'" class="sapidcms_cont_btn" />
					<input type="submit"  name="sbm" value="'.$lang["Send"].'" class="sapidcms_cont_btn" /> 
				</div>
				
				
					</td>
				</tr>
			</table>	
				
				
			</td>
			<td width="200" NOWRAP="NOWRAP" valign="top" style="vertical-align: top; padding: 30px 10px 5px 10px; font-family: Tahoma, Arial; font-size: 11px; ">
				
				<div style="width: 160px; font-family: Tahoma, Arial; font-size: 11px; background-color: #CEE4F2; border: 1px solid white; padding: 5px 5px 5px 5px; margin-bottom: 5px">
				'.$lang["AddresseeList"].':<br />
				<input type="RADIO"  onclick="empty_checkboxs(this.form)" CHECKED name="address" value="" /> '.$lang["ToEverybody"].'<br />
				<input type="RADIO" onclick="empty_checkboxs(this.form)" name="address" value="|1||2||3|" /> '.$lang["ToDevelopers"].'<br />
				</div>
				
				<div style="overflow-y: scroll; width: 160px; height: 280px; font-family: Tahoma, Arial; font-size: 11px; background-color: #CEE4F2; border: 1px solid white; padding: 5px 5px 5px 5px">
				'.$addreslist.'
				</div>
			
			</td>
		</tr>
		<tr>
			<td colspan="2" class="header" align="right">&nbsp;</td>
		</tr>
				</form>
	</table>
	</body>
	</html>

	
');	
?>